package com.caigou.modules.query.adpter

import android.graphics.Color
import android.widget.TextView
import com.caigou.comm.base.ext.prizeBallColor
import com.caigou.modules.query.R
import com.caigou.modules.query.bean.LongestCodeItemBean
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * @author #Suyghur.
 * Created on 2021/12/19
 */
class LongestCodeItemAdapter(dataset: MutableList<LongestCodeItemBean>) :
    BaseQuickAdapter<LongestCodeItemBean, BaseViewHolder>(R.layout.item_longest_code_list, dataset) {
    override fun convert(holder: BaseViewHolder, item: LongestCodeItemBean) {
        val tvName = holder.getView<TextView>(R.id.item_longest_code_tv_name)
        tvName.text = item.name
        tvName.setTextColor(Color.parseColor("#505050"))
        tvName.setBackgroundResource(0)
        if (item.tabType == 0) {
            tvName.setBackgroundResource(prizeBallColor(item.color))
        } else if (item.tabType == 1 || item.tabType == 6) {
            val color = when (item.color) {
                1 -> Color.parseColor("#FE6880")
                2 -> Color.parseColor("#3BB75B")
                else -> Color.parseColor("#5394EE")
            }
            tvName.setTextColor(color)
        }
        holder.setText(R.id.item_longest_code_tv_current, "${item.currentNotOpened}期")
        holder.setText(R.id.item_longest_code_tv_history, "${item.historyNotOpened}期")
    }
}